package com.ysd.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;
@Entity
@Table(name = "user")
public class UserInfo {
	@Id
	private String uid;
	private String uname;//用户名 
	private String state;//状态0-1
	private String passcheck;//密码
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createTime;//账户创立时间
	private String email;
	private String phone;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date updateTime;//修改时间
	private String yuliu1;
	private String yuliu2;
	private String error;
	 //外键多对一  部门id
	 @ManyToOne(cascade=CascadeType.REFRESH,fetch=FetchType.EAGER)
    @JoinColumn(name="departmentid") 
	 private  Department department;
	  
	 
		//外键多对多    角色中间表
	 @ManyToMany(fetch=FetchType.EAGER)
	 @JoinTable(
	 			name="user_roles",//指定中间表的表名
	 			joinColumns= {@JoinColumn(name="uid")},//维护方实体的外键
	 			inverseJoinColumns= {@JoinColumn(name="rid")}//被维护方实体的主键
	 			)
	List<roles>   roleList;
	 
	public List<roles> getRoleList() {
		return roleList;
	}
	public void setRoleList(List<roles> roleList) {
		this.roleList = roleList;
	}
	public UserInfo() {
		super();
		// TODO Auto-generated constructor stub
	}
	public UserInfo(String uid, String uname, String state, String passcheck, Date createTime, String email, String phone,
			Date updateTime, String yuliu1, String yuliu2, String error, Department department) {
		super();
		this.uid = uid;
		this.uname = uname;
		this.state = state;
		this.passcheck = passcheck;
		this.createTime = createTime;
		this.email = email;
		this.phone = phone;
		this.updateTime = updateTime;
		this.yuliu1 = yuliu1;
		this.yuliu2 = yuliu2;
		this.error = error;
		this.department = department;
	}
	@Override
	public String toString() {
		return "Users [uid=" + uid + ", uname=" + uname + ", state=" + state + ", passcheck=" + passcheck
				+ ", createTime=" + createTime + ", email=" + email + ", phone=" + phone + ", updateTime=" + updateTime
				+ ", yuliu1=" + yuliu1 + ", yuliu2=" + yuliu2 + ", error=" + error + ", department=" + department + "]";
	}
	public String getUid() {
		return uid;
	}
	public void setUid(String uid) {
		this.uid = uid;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getPasscheck() {
		return passcheck;
	}
	public void setPasscheck(String passcheck) {
		this.passcheck = passcheck;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	public String getYuliu1() {
		return yuliu1;
	}
	public void setYuliu1(String yuliu1) {
		this.yuliu1 = yuliu1;
	}
	public String getYuliu2() {
		return yuliu2;
	}
	public void setYuliu2(String yuliu2) {
		this.yuliu2 = yuliu2;
	}
	public String getError() {
		return error;
	}
	public void setError(String error) {
		this.error = error;
	}
	public Department getDepartment() {
		return department;
	}
	public void setDepartment(Department department) {
		this.department = department;
	}
	
	
}
